#include <algorithm>
#include <cstdio>
#include <cstring>
#define lowbit(x) (x & (-x))

const int N = 35;
int n, ans, maxans, vis, p[N], suf[N];
char tmp[N];

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("testdata.in", "r", stdin);
  freopen("testdata.out", "w", stdout);
#endif
#ifndef LOCAL
  freopen("factory.in", "r", stdin);
  freopen("factory.out", "w", stdout);
#endif
#endif

  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", tmp);
    for (int j = 0; j < n; ++j) {
      if (tmp[j] == '1') p[i] |= 1 << j;
    }
  }
  std::sort(p + 1, p + n + 1);
  do {
    ans = 0;
    vis = 0;
    memset(suf, 0, sizeof(suf));
    for (int i = n; i; --i) suf[i] = suf[i + 1] | p[i];
    for (int i = 1; i <= n; ++i) {
      if ((vis & p[i]) >= p[i]) {
        ++ans;
        vis |= lowbit(((suf[i])) & ((1 << n) - 1));
      }
      vis |= p[i];
    }
    maxans = std::max(ans, maxans);
  } while (std::next_permutation(p + 1, p + n + 1));
  printf("%d", maxans);
  return 0;
}